package com.hongxun.budget.ui.activity.ys;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.amap.api.maps.AMap;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.MapView;
import com.amap.api.maps.model.LatLng;
import com.hongxun.budget.R;
import com.hongxun.budget.ui.activity.BaseActivity;
import com.hongxun.budget.utils.DrawYsMapUtils;
import com.hongxun.budget.utils.MyAMapUtils;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 点位选择或其他点位功能
 */
public class ChoiceYsPointActivity extends BaseActivity {

    @BindView(R.id.map)
    MapView mMapView;
    AMap aMap;
    boolean isVisibleSpan;//是否显示档距
    boolean isVisibleBianhao;//是否显示编号
    Double lat, lgt;
    @BindView(R.id.right_save)
    Button rightSave;
    @Override
    public  int getLayoutId() {
        return R.layout.activity_choice_point;
    }

    @Override
    public  void initView(Bundle savedInstanceState) {
        rightSave.setText("不设置");
        rightSave.setVisibility(View.VISIBLE);
        Intent intent = getIntent();
        lat = intent.getDoubleExtra("lat", 0);
        lgt = intent.getDoubleExtra("lgt", 0);
        mMapView.onCreate(savedInstanceState);
        if (aMap == null) {
            aMap = mMapView.getMap();
        }
        DrawYsMapUtils utils = new DrawYsMapUtils(this, aMap, isVisibleSpan, isVisibleBianhao, "选择点位");
        utils.setWork(intent.getBooleanExtra("isUp", false) ? "新增" : "全部");
        utils.draw();
        aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lgt), MyAMapUtils.locationZoom));
    }
    @OnClick(R.id.right_save)
    public void onViewClicked() {
        Intent intent = new Intent();
        setResult(Activity.RESULT_OK, intent);
        finish();
    }
}
